package com.yuan.algorithms.arithmetic_1;

import java.util.Scanner;

public class 递归_求两个串的最大公共子序列长度 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String N = sc.next();
			String M = sc.next();
			System.out.println(f(N, M));
		}
	}
	
	public static int f(String s1, String s2) {
		if (s1.length()==0 || s2.length() == 0) {
			return 0;
		}
		if (s1.charAt(0)==s2.charAt(0)) {
			return f(s1.substring(1), s2.substring(1)) + 1;
		}else {
			return Math.max(f(s1.substring(1), s2), f(s1, s2.substring(1)));
		}
	}
}
